import { NgModule } from '@angular/core';
import { RouterModule, NavigationEnd, Router } from '@angular/router';

import { ConsumablesComponent } from './consumables/consumables.component';
import { LedgerComponent } from './ledger/ledger.component';
import { MachineHourComponent } from './machine-hour/machine-hour.component';
import { RepairComponent } from './repair/repair.component';
import { SparePartComponent } from './spare-part/spare-part.component';
import { FinancialCostComponent } from './financial-cost/financial-cost.component';
@NgModule({
    imports: [
        RouterModule.forChild([
            {
                path: '',
                children: [
                    { path: 'consumables', component: ConsumablesComponent },
                    { path: 'ledger', component: LedgerComponent },
                    { path: 'machine-hour', component: MachineHourComponent },
                    { path: 'repair', component: RepairComponent },
                    { path: 'spare-part', component: SparePartComponent },
                    { path: 'financial-cost', component: FinancialCostComponent }
                ]
            }
        ])
    ],
    exports: [RouterModule]
})
export class DeviceRoutingModule {
    constructor(private router: Router) {
        router.events.subscribe(event => {
            if (event instanceof NavigationEnd) {
                window.scroll(0, 0);
            }
        });
    }
}
